package NK_SEL.applogic3;

import java.util.List;

//import org.openqa.selenium.By;

import NK_SEL.applogic.FilmHelper;
import NK_SEL.model.Film;
//import NK_SEL.pages.FilmAddPage;

public class FilmHelper3 extends DriverBasedHelper implements FilmHelper{

  public FilmHelper3(ApplicationManager3 manager) {
    super(manager.getWebDriver());
  }

   @Override
   public void create(Film film) {
	  pages.internalPage.clickFilmAddPage().ensurePageLoaded()
	     .setTitleField(film.getTitle())
		 .setYearField(film.getYear())
		     .clickSaveButton();
  }

   @Override
   public void open(){
	   pages.internalPage.ensurePageLoaded()
	    .clickfilmOpen();
   }
   
   @Override
   public void delete(){
	   pages.internalPage.ensurePageLoaded()
	   .clickfilmDelete();
   }

   @Override
   public void notDelete(){
	   pages.internalPage.ensurePageLoaded()
	   .clickfilmNotDelete();
   }
   @Override
   public List<Film> search(String title) {
     pages.internalPage.clickFilmSearch(title).waitload(3000);
   return null;
  }
   
   @Override
   public boolean isCreated(){
	 return  !isTextPresent("This field is required");  
   }
   
   @Override
   public boolean isNotCreated(){
     return isTextPresent("This field is required");
   }
   @Override
   public boolean isDeleted(){
	 return  isTextPresent("Add movie") &&
			 isTextPresent("Update all");  
   }
      
   @Override
   public boolean isEmptyList() {
	   return isTextPresent("No movies");
   // return !isElementPresentByCSS("div.nocover");   
   }
    
   @Override
   public boolean notEmptyList() {
	 //return isTextPresent("No movies");
     return isElementPresentByCSS("div.nocover");   
   }
}

